
//
//  ByCellUserIndexBranch.m
//  jinpuyiyuan_ios
//
//  Created by pro on 2017/12/14.
//  Copyright © 2017年 mc. All rights reserved.
//

#import "ByCellUserIndexBranch.h"

@implementation ByCellUserIndexBranch
{
    UIImageView *_img;
    UILabel     *_titleLabel;
    UILabel     *_addressLabel;
    UILabel     *_phoneLabel;
}

+ (instancetype)cellWithTableView:(UITableView*)tableView{
    
    static NSString *cellIdentifier = @"ByCellUserIndexBranch";
    ByCellUserIndexBranch *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
    if (cell == nil) {
        cell = [[self alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
    }
    return cell;
}
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.selectionStyle = UITableViewCellSeparatorStyleNone;
        [self createViews];
    }
    return self;
}

- (void)createViews{
    _img = [[UIImageView alloc] init];
    [self addSubview:_img];
    [_img mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(@(10));
        make.top.equalTo(@(10));
        make.size.mas_equalTo(CGSizeMake(70, 70));
    }];
    
    _titleLabel = [[UILabel alloc] init];
    [self addSubview:_titleLabel];
    [_titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(_img.mas_right).offset(15);
        make.top.equalTo(@(15));
        make.right.equalTo(@(0));
        make.height.equalTo(@(20));
    }];
    _titleLabel.font = FONT(15);
    
    _addressLabel = [[UILabel alloc] init];
    [self addSubview:_addressLabel];
    [_addressLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(_img.mas_right).offset(15);
        make.top.equalTo(_titleLabel.mas_bottom).offset(10);
        make.right.equalTo(@(0));
        make.height.equalTo(@(15));
    }];
    _addressLabel.font = FONT(13);
    
    _phoneLabel = [[UILabel alloc] init];
    [self addSubview:_phoneLabel];
    [_phoneLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(_img.mas_right).offset(15);
        make.top.equalTo(_addressLabel.mas_bottom);
        make.right.equalTo(@(0));
        make.height.equalTo(@(15));
    }];
    _phoneLabel.font = FONT(13);
}

- (void)setModel:(ByModelIndexBranch *)model{
    [_img sd_setImageWithURL:[NSURL URLWithString:BOYE_PICTURE_VIEW_URL(model.icon)] placeholderImage:nil];
    _titleLabel.text = model.name;
    _addressLabel.text = [NSString stringWithFormat:@"地址：%@",model.address];
    _phoneLabel.text = [NSString stringWithFormat:@"电话：%@",model.link_phone];
}

@end
